<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<style>
    li{
        list-style: none;
    }
    img{
        width: 300px;
        height: 400px;
    }
    .texts{
        padding-left: 500px;
        border: 1px solid red;
    }
</style>
<body>
    <div class="texts">
        <img src="2.jpg" alt="">
        <li>
            <h4>纪梵希口红</h4>
            ￥:<span id="price">340</span>
        </li>
        <p>数量：<input type="button" value="-" id="jian">
            <input type="text" id="num" value="0">
            <input type="button" value="+" id="jia"><br/>
            总价：<span id="total">0.00</span>
        </p>
    </div>
</body>

</html>
<script>
   jian.onclick=function (){
    if(num.value>0){
       num.value--;
       total.innerHTML = (price.innerHTML * 1 * num.value * 1).toFixed(2);
    }
   }
   jia.onclick=function (){
       
       num.value++;
       total.innerHTML = (price.innerHTML * 1 * num.value * 1).toFixed(2);
   
   }
</script>